<?php
namespace Home\Controller;
use Think\Controller;
class RegisterController extends Controller{
	function index(){
		$this->display();
	}
	function zhuce(){
		$user = new \Think\Model('User');

		$username=$_POST['username'];
		$password=$_POST['password'];
		//方法1方法1方法1
		// $crs=$user->data($_POST)
		// 		  ->add();
		// if($crs){
		// 		$this->success('注册成功',U('Home/Login/index'));
		// 	}else{
		// 		$this->error('注册失败',U('Home/Register/index'));
		// 	}
	 	
		//方法2方法方法2
		$rs=$user->create();
		if($rs){
			$crs=$user->add();
			if($crs){
				$this->success('注册成功',U('Home/Login/index'));
			}else{
				$this->error('注册失败',U('Home/Register/index'));
			}
		}else{
			$info=$user->getError();
			$this->error($info,U('Home/Register/index'));
		}
		
	}
}
